Johannesburg , South Africa -LRB- CNN -RRB- -- President Barack Obama held a town hall meeting Saturday with a group of young people in the Soweto section of Johannesburg , with video links to similar groups in other cities in Africa .

Here are five things that he said in response to questions from the participants in a format he called `` a little humbling '' but energizing . CNN Johannesburg correspondent Nkepile Mabuse moderated the town hall .

Praise for Mandela

Obama paid homage to former South African President Nelson Mandela , the 94-year-old founding father of the country 's modern democracy who is in critical condition in a Pretoria hospital . `` Obviously , he is on our minds today , and we join the people of the world in sending our prayers to Madiba and his family , because he still inspires us all , '' Obama said , referring to Mandela by his clan name .

Obama noted that Mandela held on to his optimism during his 27 years in prison under South Africa 's apartheid regime , and he urged his audience to learn from that . `` There will be time to test your faith , but no matter how old you grow , I say ... do n't lose those qualities of youth : your imagination , your optimism , your idealism , 'cause the future of this continent is in your hands , and if you keep your head pointed toward the sun , and you keep your feet moving forward , I promise you will have no better friend and partner than the United States of America . ''

Mandela showed that `` through a commitment to the constitution and rule of law and equal treatment for all people that a country can prosper despite a tragic history . ''

Obama meets with Mandela 's family in South Africa

A bright view of Africa 's future

Africa 's role in the world economy as a provider of raw materials to other parts of the world dates back to colonial days and must be changed , Obama said . Though foreign aid remains critical in some parts of the continent , `` It is very clear that people want to break out of a dependency trap . The idea is not that Africa should be the ward of some other country . What we need is an Africa that 's building , manufacturing , creating value , inventing and then sending those products around the world and receiving products in return . ... If we do that , there 's no reason why Africa can not succeed . ''

Progress against terrorism

Though `` some progress '' has been made in dealing with extremist groups , `` the problem has metastasized '' to include more regional terrorist organizations such as Boko Haram in Nigeria , Obama said . `` Though they may not have the same transnational capacity that some of the earlier organizations did , they 're doing great harm in Africa and in the Middle East and in South Asia . ''

The terrorist threat affects more than Western countries , he said . `` The number of people killed by terrorist attacks in Africa or South Asia far outstrips deaths by Westerners , '' he said . `` This is not just a problem for us ; this is a problem for everybody . ''

Terrorism is more likely to emerge in countries that are not delivering for their people , `` and where there are areas of conflict and underlying frustrations '' that have not been adequately dealt with , he said .

He cited responsive governance and strong democratic institutions as bulwarks against terrorism taking root . `` They 're the most important defense against terrorism . ''

American ambitions

Obama rejected `` this notion that we want to somehow expand our military reach , '' citing the end of the war in Iraq and plans to end the war in Afghanistan as evidence . `` This idea somehow that we want to get more involved militarily around the world is simply not true , '' he said . `` First of all , it costs a lot of money , and the United States -- just like every country around the world -- has to think about its budget . And where we intervene , oftentimes it 's not very effective because , unless you 've got a local population that is standing up against terrorism , we end up being viewed as interlopers and intruders . ''

He said he wants the African Union and other regional organizations to beef up their capacity to send peacekeepers `` to nip terror cells that may be forming -- before they start and gain strength . ''

The United States , he added , can provide advice , training and , in some cases , equipment .

Global warming looms

The world 's biggest environmental challenge is climate change , Obama said , adding that carbon emissions are warming the planet and threaten to cause the problem to spin out of control . `` We are going to all have to work together to find ways in which , collectively , we reduce carbon , '' but wealthy countries must do more than companies that are still developing , he said . `` Obviously , they should n't be resigned to poverty simply because the West and Europe and America got there first . That would n't be fair , but everybody 's going to have to do something . ''

If , however , everyone buys cars , installs air conditioners and moves into big houses , `` the planet will boil over unless we find new ways of producing energy , '' he said .

@highlight

`` Do n't lose those qualities of youth , '' President Obama urges his audience

@highlight

Africans want to break out of the `` dependency trap , '' he says

@highlight

Wars cost `` a lot of money , '' says Obama , downplaying U.S. military ambitions

@highlight

`` Everybody 's going to have to do something '' on climate change , he says